<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>
<title></title>
  <style type="text/css">
    <!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
  </style>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head><body>


<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = -->
<!-- =   Java2Html Converter 4.2 [2006-01-05] by Markus Gebhard  markus@jave.de   = -->
<!-- =     Further information: http://www.java2html.de     = -->
<div align="left" class="java">
<table border="2" cellpadding="3" cellspacing="0" bgcolor="#ffffff">
  <!-- start headline -->
   <tr>
    <td colspan="2">
     <center><font size="+2">
      <code><b>
Node.java
      </b></code>
     </font></center>
    </td>
   </tr>
  <!-- end headline -->
   <tr>
  <!-- start source code -->
   <td nowrap="nowrap" valign="top" align="left">
    <code>
<font color="#808080">01</font>&nbsp;<font color="#7f0055"><b>package&nbsp;</b></font><font color="#000000">org.jbpm.gop;</font><br />
<font color="#808080">02</font>&nbsp;<font color="#ffffff"></font><br />
<font color="#808080">03</font>&nbsp;<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">java.util.*;</font><br />
<font color="#808080">04</font>&nbsp;<font color="#ffffff"></font><br />
<font color="#808080">05</font>&nbsp;<font color="#3f5fbf">/**&nbsp;a&nbsp;node&nbsp;in&nbsp;the&nbsp;process&nbsp;graph&nbsp;*/</font><br />
<font color="#808080">06</font>&nbsp;<font color="#7f0055"><b>public&nbsp;class&nbsp;</b></font><font color="#000000">Node&nbsp;</font><font color="#000000">{</font><br />
<font color="#808080">07</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><br />
<font color="#808080">08</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">String&nbsp;name;</font><br />
<font color="#808080">09</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;maps&nbsp;events&nbsp;to&nbsp;transitions&nbsp;*/</font><br />
<font color="#808080">10</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">Map&lt;String,Transition&gt;&nbsp;transitions&nbsp;=&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">HashMap&lt;String,Transition&gt;</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#808080">11</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;maps&nbsp;events&nbsp;to&nbsp;actions&nbsp;*/</font><br />
<font color="#808080">12</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">Map&lt;String,List&lt;Action&gt;&gt;&nbsp;actions&nbsp;=&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">HashMap&lt;String,List&lt;Action&gt;&gt;</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#808080">13</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><br />
<font color="#808080">14</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#000000">Node</font><font color="#000000">(</font><font color="#000000">String&nbsp;name</font><font color="#000000">)&nbsp;{</font><br />
<font color="#808080">15</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>this</b></font><font color="#000000">.name&nbsp;=&nbsp;name;</font><br />
<font color="#808080">16</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">17</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><br />
<font color="#808080">18</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;create&nbsp;a&nbsp;new&nbsp;transition&nbsp;to&nbsp;the&nbsp;destination&nbsp;node&nbsp;and&nbsp;</font><br />
<font color="#808080">19</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;associate&nbsp;it&nbsp;with&nbsp;the&nbsp;given&nbsp;event&nbsp;*/&nbsp;</font><br />
<font color="#808080">20</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">addTransition</font><font color="#000000">(</font><font color="#000000">String&nbsp;event,&nbsp;Node&nbsp;destination</font><font color="#000000">)&nbsp;{</font><br />
<font color="#808080">21</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">transitions.put</font><font color="#000000">(</font><font color="#000000">event,&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">Transition</font><font color="#000000">(</font><font color="#000000">destination</font><font color="#000000">))</font><font color="#000000">;</font><br />
<font color="#808080">22</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">23</font>&nbsp;<font color="#ffffff"></font><br />
<font color="#808080">24</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;add&nbsp;the&nbsp;action&nbsp;to&nbsp;the&nbsp;given&nbsp;event&nbsp;*/</font><br />
<font color="#808080">25</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">addAction</font><font color="#000000">(</font><font color="#000000">String&nbsp;event,&nbsp;Action&nbsp;action</font><font color="#000000">)&nbsp;{</font><br />
<font color="#808080">26</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">actions.containsKey</font><font color="#000000">(</font><font color="#000000">event</font><font color="#000000">))&nbsp;{</font><br />
<font color="#808080">27</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">actions.get</font><font color="#000000">(</font><font color="#000000">event</font><font color="#000000">)</font><font color="#000000">.add</font><font color="#000000">(</font><font color="#000000">action</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">28</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}&nbsp;</font><font color="#7f0055"><b>else&nbsp;</b></font><font color="#000000">{</font><br />
<font color="#808080">29</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">List&lt;Action&gt;&nbsp;eventActions&nbsp;=&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">ArrayList&lt;Action&gt;</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#808080">30</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">eventActions.add</font><font color="#000000">(</font><font color="#000000">action</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">31</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">actions.put</font><font color="#000000">(</font><font color="#000000">event,&nbsp;eventActions</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">32</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">33</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">34</font>&nbsp;<font color="#ffffff"></font><br />
<font color="#808080">35</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;to&nbsp;be&nbsp;overriden&nbsp;by&nbsp;Node&nbsp;implementations.&nbsp;The&nbsp;default&nbsp;doesn't&nbsp;</font><br />
<font color="#808080">36</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;propagate&nbsp;the&nbsp;execution&nbsp;so&nbsp;it&nbsp;behaves&nbsp;as&nbsp;a&nbsp;wait&nbsp;state.&nbsp;*/</font><br />
<font color="#808080">37</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">execute</font><font color="#000000">(</font><font color="#000000">Execution&nbsp;execution</font><font color="#000000">)&nbsp;{</font><br />
<font color="#808080">38</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">System.out.println</font><font color="#000000">(</font><font color="#2a00ff">&#34;arrived&nbsp;in&nbsp;wait&nbsp;state&nbsp;&#34;</font><font color="#000000">+</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">39</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">40</font>&nbsp;<font color="#ffffff"></font><br />
<font color="#808080">41</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#000000">String&nbsp;toString</font><font color="#000000">()&nbsp;{&nbsp;</font><font color="#7f0055"><b>return&nbsp;</b></font><font color="#2a00ff">&#34;node&nbsp;'&#34;</font><font color="#000000">+name+</font><font color="#2a00ff">&#34;'&#34;</font><font color="#000000">;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">42</font>&nbsp;<font color="#000000">}</font></code>

   </td>
  <!-- end source code -->
   </tr>
</table>
</div>
<!-- =       END of automatically generated HTML code       = -->
<!-- ======================================================== -->


</body></html>